﻿using System;
using System.Data;
using System.Collections.Generic;
using ZHDJ.MobileInterface.Common;
using SXT.Party.Law.Model;
/*律师评价*/

namespace ZHDJ.MobileInterface
{
    public partial class GetLawyerEvaluation : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象  
            LawyerEvaluationOutParam result = new LawyerEvaluationOutParam();
            LawyerEvaluationInParam param = new LawyerEvaluationInParam();
            string logMsg = "";
            bool isFlag = true;

            try
            {
                param = inParam as LawyerEvaluationInParam;


                if (param.page_no * param.page_count <= 0)
                {
                    result.code = "0";
                    result.desc = "当前页,以及页记录条数必须为大于0的正整数";

                    isFlag = false;
                }

                if (string.IsNullOrEmpty(param.LawyerID))
                {
                    result.code = "0";
                    result.desc = "律师ID不能为空";

                    isFlag = false;
                }

                if (isFlag)
                {
                    DataSet ds = PartyLawEvaluation.GetGridDataPage(param.page_no, param.page_count, param.LawyerID, "MobileService");
                    if (ds != null && ds.Tables.Count == 2&&ds.Tables[0].Rows.Count>0)
                    {
                        LawyerEvaluationData itemTemp;
                        result.data.total_pages = CommonUtils.GetTotalPages(Convert.ToInt32(ds.Tables[1].Rows[0][0]), param.page_count);
                        result.LawyerName = ds.Tables[0].Rows[0]["UserName"].ToString();
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            itemTemp = new LawyerEvaluationData();
                            itemTemp.Level = dr["Level"].ToString();
                            itemTemp.CreateTime = dr["CreateTime"].ToString();

                            result.data.list.Add(itemTemp);
                        }
                    }
                }

                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员";
                logMsg = ex.Message + ":" + ex.StackTrace;
            }

            CommonUtils.InsertMobileInterfaceLog(SystemCode + "-GetLawyerEvaluation", SerializeHelper.JsonSerializer<LawyerEvaluationInParam>(param), logMsg);
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<LawyerEvaluationInParam, LawyerEvaluationOutParam>();
            else
                SafeProcessRequest<LawyerEvaluationInParam, LawyerEvaluationOutParam>();
        }
    }

    #region 请求参数
    public class LawyerEvaluationInParam
    {
        /// <summary>
        /// 必填 当前页
        /// </summary>
        public int page_no
        { get; set; }

        /// <summary>
        /// 必填，每页记录条数
        /// </summary>
        public int page_count
        { get; set; }

        /// <summary>
        /// 律师ID
        /// </summary>
        public string LawyerID
        { get; set; }

    }
    #endregion


    #region 结果参数
    public class LawyerEvaluationOutParam
    {
        public LawyerEvaluationOutParam()
        {
            code = "1";
            desc = "操作成功";
            data = new LawyerEvaluationList();
        }

        public string code
        { get; set; }

        public string desc
        { get; set; }

        /// <summary>
        /// 律师名称
        /// </summary>
        public string LawyerName
        { get; set; }

        public LawyerEvaluationList data
        { get; set; }

    }

    public class LawyerEvaluationList
    {
        public LawyerEvaluationList()
        {
            total_pages = 0;
            list = new List<LawyerEvaluationData>();
        }

        public List<LawyerEvaluationData> list { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int total_pages
        { get; set; }
    }

    public class LawyerEvaluationData
    {
        /// <summary>
        /// ID
        /// </summary>
        public string EvaluationID
        { get; set; }

        /// <summary>
        /// 评价等级  1：好评 2：中评 3：差评
        /// </summary>
        public string Level
        { get; set; }

        /// <summary>
        /// 评价时间
        /// </summary>
        public string CreateTime
        { get; set; }
    }
    #endregion
}